package com.androkick.soundrecordercaller;

import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.provider.MediaStore.Audio;
import android.widget.Toast;

public class SoundRecorderCaller extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        Intent intent = new Intent(Audio.Media.RECORD_SOUND_ACTION);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        
        PackageManager pm = getPackageManager();
        List<ResolveInfo> activities = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
        if (activities.size() != 0) {
            startActivity(intent);
            finish();
        } else {
            Toast.makeText(this, "SoundRecorder not visible.", Toast.LENGTH_LONG).show();
            finish();
        }
    }
}